package com.atguigu.gulimall.juc.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo {
    private static final int COUNT_BITS = Integer.SIZE - 3;
    private static final int RUNNING    = -1 << COUNT_BITS;
    private static final int SHUTDOWN   =  0 << COUNT_BITS;
    private static final int STOP       =  1 << COUNT_BITS;
    private static final int TIDYING    =  2 << COUNT_BITS;
    private static final int TERMINATED =  3 << COUNT_BITS;
    private static final int CAPACITY   = (1 << COUNT_BITS) - 1;
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        System.out.println(COUNT_BITS);
        System.out.println("RUNNING: "+RUNNING);
        System.out.println("SHUTDOWN: "+SHUTDOWN);
        System.out.println("STOP: "+STOP);
        System.out.println("TIDYING: "+TIDYING);
        System.out.println("TERMINATED: "+TERMINATED);
        System.out.println("CAPACITY: "+CAPACITY);
        System.out.println("CAPACITY: "+(0 & ~CAPACITY));
        System.out.println("CAPACITY2: "+ ~CAPACITY);
        System.out.println("CAPACITY3: "+ (4 & CAPACITY));
        System.out.println("ctl: "+ (RUNNING | 0));

        executorService.execute(()->{
            System.out.println(Thread.currentThread().getName()+"办理业务");
        });

    }
}
